# send的作用是唤醒并继续执行，发送一个信息到生成器内部

def foo():
    print("start")
    i = 0
    while i < 2:
        temp = yield i
        print(f"temp:{temp}")
        i = i + 1
    print("end")


g = foo()
print(next(g))
print("*" * 20)
print(g.send(100))
print(next(g))

"""
运算结果：
start
0
********************
temp:100
1
temp:None
end
Traceback (most recent call last):
File
"C:\Users\webChubby\PycharmProjects\网络编程\test.py", line 14, in <module>
print(next(g))
StopIteration
"""